<template>
  <div class="history-song-item">
    <div class="left">
      <img :src="item.al ? item.al.picUrl : item.picUrl" alt="" />

      <span>{{ currentPlayCount }}</span>
    </div>

    <div class="middle">
      <div class="top e_1">
        {{ item.name }}
        <span v-if="(item.song ? item.song.alias : item.alia).length">
          ({{ item.song ? item.song.alias[0] : item.alia[0] }})
        </span>
      </div>

      <div class="bottom e_1">
        <span
          v-for="ar in item.song ? item.song.artists : item.ar"
          :key="ar.id"
          >{{ ar.name }}</span
        >
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "RecentSingleItem",
  props: {
    item: Object,
    playData: Array | [],
  },
  computed: {
    ...mapState(["currentSong", "playing", "playlist", "currentTime"]),

    currentPlayCount() {
      const index = this.playData.findIndex((song) => {
        return this.currentSong.id === song.id;
      });
      return this.playData[index].playCount;
    },
  },

  watch: {
    currentPlayCount(n) {
      console.log(n);
    },
  },
};
</script>

<style lang="less" scoped>
.history-song-item {
  width: 100%;
  height: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;

  .left {
    width: 50px;
    height: 100%;
    position: relative;

    img {
      border-radius: 10px;
    }

    span {
      position: absolute;
      right: 10px;
      bottom: 0;
      color: #fff;
    }
  }

  .middle {
    flex: 1;
    padding-left: 20px;

    .top {
      span {
        color: #707070;
      }
    }

    .bottom {
      font-size: 12px;
      color: #707070;

      span {
        &::after {
          content: "/";
        }

        &:last-of-type {
          &::after {
            content: "";
          }
        }
      }
    }
  }

  .right {
    width: 20px;
    height: 100%;
    text-align: center;
    line-height: 50px;
  }
}
</style>
